#ifndef LEETCODE_CN_CPP_PROBLEMS_215_H
#define LEETCODE_CN_CPP_PROBLEMS_215_H

#include <queue>
#include <vector>

using namespace std;

namespace problem_215
{

class Solution
{
public:
    int findKthLargest(vector<int> &nums, int k)
    {
        priority_queue<int, vector<int>, greater<>> pq;
        for (auto n : nums)
        {
            pq.emplace(n);
            if (pq.size() > k)
                pq.pop();
        }
        return pq.top();
    }
};

} // namespace problem_215

#endif //LEETCODE_CN_CPP_PROBLEMS_215_H
